jQuery(document).ready(function() {
	function newsPages() {
		jQuery.getJSON("servlet/NewsPageServlet", page);
		function page(data){
			var $newPages = jQuery(".mem_tab").empty();
			var news = data.newsList
			$newPages.append("<tr>"
					+"<td width=\"500\" style=\"text-align: center;\">文章标题</td><td width=\"430\" style=\"text-align: center;\">创建时间</td>"
			)

			for(var a = 0; a<news.length;a++){
				$newPages.append("<tr>"
						+"<td width=\"500\" style=\"text-align: center;\"><a class='dian' id='"+news[a].id+"' href='javascript:;'>"+news[a].title+"</a></td>"
						+"<td width=\"430\" style=\"text-align: center;\">"+news[a].createTime+"</td>"
					    +"</tr>");
			}
		
	$first=jQuery("<a href=\"javascirpt:;\" class=\"p_pre\">上一页</a>").click(function(){
		jQuery.getJSON("servlet/NewsPageServlet","pageIndex="+(data.currPageNo-1),page);
	});
	$last =jQuery("<a href=\"javascirpt:;\" class=\"p_pre\">下一页</a>").click(function(){
		jQuery.getJSON("servlet/NewsPageServlet","pageIndex="+(data.currPageNo+1),page);
	});
	var $page = jQuery(".pages").empty();
	$page.append($first).append($last);
		}
	}
	newsPages();
	jq(".m_right").on("click", ".dian", function() {
		var aa=this.id 
		var $newPages = jQuery(".m_right").empty();
			jQuery.getJSON("servlet/NewsPageServlet","id="+aa, page);
			function page(data){
					$newPages.append("<h3>"+data[0].title+"</h3><div>"+data[0].content+"</div>");
			}
	});

});